package model;

import java.util.Enumeration;
import java.util.Vector;

import dao.CustomerDAO;

public class ListCustomer {
	private CustomerDAO customerDAO;
	private Vector customers;

	public ListCustomer() {
		customers = new Vector();
	}

	public void connect() {
		customerDAO = new CustomerDAO();
		customers = customerDAO.getListcustomer();
	}

	public boolean addcustomer(Customer e) {
		boolean re = false;
		try {
			customers.addElement(e);
			customerDAO.insert_Customer(e);
		} catch (Exception er) {
			re = false;
		}
		return re;
	}
	
	

	// search by (id, name, creditcard,phonenumber,.....)
	// search by id
	public Customer getCustomerByID(int id) {
		Enumeration emp = customers.elements();
		while (emp.hasMoreElements()) {
			Customer each = (Customer) emp.nextElement();
			if (id == each.getCustomer_id()) {
				return each;
			}
		}
		return new Customer();
	}
}
